﻿<div ms-controller="LIST">
    <div class="btn-add">
        <button type="button" ms-if="JHDATA.JHStatus=='0'" class="btn btn-success btn-lg" ms-click="AddViewNOWF('JHSR/JHSR&JHID='+JHDATA.ID)"><i class=" iconfont icon-jiahao ft12 mr5"></i>添加收入明细</button>
        <button type="button" ms-if="JHDATA.JHStatus=='0'&&(datatype=='0'||datatype=='-1')" class="btn btn-info btn-lg" ms-click="tempindex.comp()"><i class=" iconfont icon-jiahao ft12 mr5"></i>填毕</button>
        <button type="button" ms-if="JHDATA.JHStatus=='0'&&(datatype=='0'||datatype=='-1')" class="btn btn-info btn-lg" ms-click="tempindex.edit()"><i class=" iconfont icon-bianji ft12 mr5"></i>编辑</button>
        <button type="button" ms-if="JHDATA.JHStatus=='0'&&(datatype=='0'||datatype=='-1')" class="btn btn-danger btn-lg" ms-click="tempindex.del()"><i class=" iconfont icon-shanchu ft12 mr5"></i>删除</button>
    </div>
    <!--<div class="tab-filter-type" style="padding-left:30px">
        <h3><span style="font-size: 24px">计划名称：{{JHDATA.JHTitle}}</span> <span class="label label-default"  ms-if="JHDATA.JHStatus=='1'">已关闭</span>  <span class="label label-success"  ms-if="JHDATA.JHStatus=='0'">进行中</span></h3>
    </div>-->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">类型：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectDataType('0')"><span class="active">未填毕</span></li>
                <li ms-click="SelectDataType('1')"><span>审核中</span></li>
                <li ms-click="SelectDataType('2')"><span>审核通过</span></li>
                <li ms-click="SelectDataType('3')"><span>已上报</span></li>
                <li ms-click="SelectDataType('4')"><span>已中止</span></li>
                <li ms-click="SelectDataType('5')"><span>已执行</span></li>
                <li ms-click="SelectDataType('-1')"><span>被拒绝</span></li>


            </ul>
        </div>
    </div>
    <div class="default-tab ft14 pt20 grid" style="margin-top: 10px">

        <div id="jqxgrid" class="jqxgrid" style="border-right: 0; border-left: 0;"></div>

    </div>
</div>
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.base.css" />
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.office.css" />
<script src="/VIEWV5/JS/YanGrid/jqwidgets/jqgridall.js"></script>
<script>
    var goption = {
        columnsresize: true,
        columns: [

                   {
                       text: '1', dataField: 'issel', columntype: 'checkbox', width: 40, editable: true, sortable: false, filterable: false, groupable: false, draggable: false, resizable: false,
                       renderer: function () {
                           return '<div style="margin-left: 10px; margin-top: 5px;"></div>';
                       },
                       rendered: function (element) {
                           $(element).jqxCheckBox({ theme: "office", width: 16, height: 16, animationShowDelay: 0, animationHideDelay: 0 });
                           // columnCheckBox = $(element);
                           $(element).on('change', function (event) {
                               var checked = event.args.checked;
                               if (checked == null || false) return;
                               var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
                               $("#jqxgrid").jqxGrid('beginupdate');

                               if (checked) {
                                   $("#jqxgrid").jqxGrid('selectallrows');
                               }
                               else if (checked == false) {
                                   $("#jqxgrid").jqxGrid('clearselection');
                               }

                               for (var i = 0; i < rowscount; i++) {
                                   $("#jqxgrid").jqxGrid('setcellvalue', i, 'issel', event.args.checked);
                               }

                               $("#jqxgrid").jqxGrid('endupdate');
                           });
                           return true;
                       }
                   },
                //{
                //    text: '操作', dataField: 'CRUser', sortable: false, filterable: false, editable: false, width: 150,pinned: true,align:'center',
                //    groupable: false, draggable: false, resizable: false, cellsrenderer: function (row, column, value) {
                //        var data = $('#jqxgrid').jqxGrid('getrowdata', row);
                //        var html = "";
                //        switch (data.status) {
                //            case "0":
                //                html = '<a href="#" onclick="tempindex.comp(\'' + data.ID + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">填毕</p></a><a href="#" onclick="tempindex.edit(\'' + data.ID + '\')"><p class="text-error" style="display: inline;margin-left: 20px;font-size: 16px; color: blue; ">编辑</p></a><a href="#" onclick="tempindex.del(\'' + data.ID + '\')"><p class="text-error" style="display: inline;margin-left: 20px;font-size: 16px;    color: Red;">删除</p></a>';
                //                break;
                //            case "1":
                //                desc = "审核中";
                //                break;
                //            case "2":
                //                desc = "审核通过";
                //                break;
                //            case "3":
                //                desc = "已上报";
                //                break;
                //            case "-1":
                //                html = '<a href="#" onclick="tempindex.comp(\'' + data.ID + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">填毕</p></a><a href="#" onclick="tempindex.edit(\'' + data.ID + '\')"><p class="text-error" style="display: inline;margin-left: 20px;font-size: 16px; color: blue; ">编辑</p></a><a href="#" onclick="tempindex.del(\'' + data.ID + '\')"><p class="text-error" style="display: inline;margin-left: 20px;font-size: 16px;    color: Red;">删除</p></a>';
                //                break;
                //            default:
                //                desc = "等待上报";
                //                break;
                //        }

                //        var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: center; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + html + '</div>';
                //        return returns;
                //    }
                //},
              { text: 'ID', dataField: 'ID', hidden: "hides" },
              { text: '备注1', dataField: 'statusremark', hidden: "hides" },
              { text: '单位名称', dataField: 'dwname', minwidth: 100, editable: false },
              { text: '项目期别', dataField: 'Remark1', minwidth: 100, editable: false },
              { text: '计划科目', dataField: 'FLName', minwidth: 80, editable: false },
              { text: '产品类型', dataField: 'cplxname', minwidth: 80, editable: false },
              { text: '回款类型', dataField: 'hklxname', minwidth: 80, editable: false },
              { text: '金额小计', dataField: 'jexj', cellsformat: 'c2', aggregates: ['sum'], editable: false },
              { text: '第一月', dataField: 'je1', cellsformat: 'c2', aggregates: ['sum'], editable: false },
              { text: '第二月', dataField: 'je2', editable: false },
              { text: '第三月', dataField: 'je3', editable: false },
              { text: '第一月描述', dataField: 'je1dec', editable: false },
              { text: '第二月描述', dataField: 'je2dec', editable: false },
              { text: '第三月描述', dataField: 'je3dec', editable: false },
              { text: '流程ID', dataField: 'intProcessStanceid', editable: false, hidden: "hides" },
              { text: '备注', dataField: 'remark', editable: false },
              { text: '第一周', dataField: 'week1', cellsformat: 'c2', aggregates: ['sum'], editable: false },
              { text: '第二周', dataField: 'week2', editable: false },
              { text: '第三周', dataField: 'week3', editable: false },
              { text: '第四周', dataField: 'week4', editable: false },
            {
                text: '计划状态', dataField: 'status', cellsrenderer: function (row, column, value) {
                    var data = $('#jqxgrid').jqxGrid('getrowdata', row);
                    var desc = ComFunJS.jhsrstatus(data.status, data);

                    var html = "";
                    html = '<a href="#" onclick="tempindex.shxq(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">' + desc + '</p></a>';
                    var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + html + '</div>';
                    return returns;
                }
            }


        ]
    };

    var tempindex = avalon.define({
        $id: "LIST",
        tmpListData: [],
        JHDATA: {},
        selids: "",
        datatype: "0",
        SelectDataType: function (type) {
            tempindex.datatype = type;
            tempindex.GetLIST();

        },
        shxq: function (row) {
            var data = $('#jqxgrid').jqxGrid('getrowdata', row);
            
            ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD_WF.html?FormCode=JHSR_JHSR&JHID=" + tempindex.JHDATA.ID + "&ID=" + data.ID + "&PIID=" + data.intProcessStanceid + "&r=" + Math.random(), "查看", "1000");
        },
        InitWigetData: function (obj) {
            tempindex.JHDATA = model.JHDATA;
            //显示的列名
            tempindex.GetLIST();
            $(".tab-box li").each(function (i) {
                $(this).click(function () {
                    $(this).addClass("active").siblings().removeClass("active");
                    $("#wrap>div:eq(" + i + ")").show().siblings().hide();
                });
            });

        },
        getcheckid: function () {
            tempindex.selids = "";
            var rowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
            for (var i = 0; i < rowindexes.length; i++) {
                var data = $('#jqxgrid').jqxGrid('getrowdata', rowindexes[i]);
                if (i == 0) {
                    tempindex.selids = data.ID;
                } else {
                    tempindex.selids = tempindex.selids + "," + data.ID;

                }
            }
            return tempindex.selids;
        },

        comp: function () {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            ComFunJS.winconfirm("确认要填毕明细吗", function () {
                $.getJSON('/API/VIEWAPI.ashx?Action=JHSR_TIANBI', { P1: tempindex.selids }, function (result) {
                    if (result.ErrorMsg == "") {
                        ComFunJS.winsuccess("操作成功");
                        setTimeout(" model.refpage()", 500)
                    }
                })
            }, function () { })
        },
        del: function (dataid) {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            ComFunJS.winconfirm("确认要删除明细吗", function () {
                $.post("/API/VIEWAPI.ashx?Action=JHSR_DEL", { P1: tempindex.selids }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        ComFunJS.winsuccess("操作成功");
                        setTimeout(" model.refpage()", 500)

                    }
                })
            }, function () { })

        },
        edit: function () {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            if (tempindex.selids.toString().split(",").length > 1) {
                ComFunJS.winwarning("只能选择一条数据进行操作！");
                return;
            };
            model.EditViewNOWF('JHSR/JHSR&JHID=' + tempindex.JHDATA.ID, tempindex.selids, '', null)
        },

        GetLIST: function () {
            try {
                $('#jqxgrid').jqxGrid('destroy');

            } catch (e) {

            }
            $(".grid").append('<div id="jqxgrid" class="jqxgrid" style="border-right:0;border-left:0;"></div>')
            $.getJSON('/API/VIEWAPI.ashx?Action=JHSR_GETJHMXLIST', { P1: tempindex.JHDATA.ID, P2: tempindex.datatype }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    for (var i = 0; i < resultData.Result.length; i++) {
                        resultData.Result[i].issel = "false";
                    }
                    ComFunJS.inithighgrid(goption, resultData.Result, "jqxgrid");
                    tempindex.tmpListData = resultData.Result;
                    $("#jqxgrid").jqxGrid('autoresizecolumns');

                }
            })
        }
    }) //@ sourceURL=JHSR_SHMXLIST.js;
</script>
